package com.lvan.rabbitboot.workqueues;

import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * 多个消费者
 * @author Lvan
 */
@Component
public class WorkConsumer {

    /**
     * 消费者1
     * @param message 消息
     */
    @RabbitListener(queuesToDeclare = @Queue(value = "work",durable = "false", autoDelete = "true"))
    public void receive1(String message) throws InterruptedException {
        System.out.println("receive-1: " + message);
        Thread.sleep(100);
    }

    /**
     * 消费者2
     * @param message 消息
     */
    @RabbitListener(queuesToDeclare = @Queue(value = "work",durable = "false", autoDelete = "true"))
    public void receive2(String message) {
        System.out.println("receive-2: " + message);
    }


}
